package com._520it.crm.service.impl;

import com._520it.crm.domain.Organization;
import com._520it.crm.mapper.OrganizationMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IOrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by 呆 on 2017/10/3.
 */
@Service
public class OrganizationServiceImpl implements IOrganizationService {
    @Autowired
    private OrganizationMapper organizationMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return organizationMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Organization organization) {
        return organizationMapper.insert(organization);
    }

    @Override
    public Organization selectByPrimaryKey(Long id) {
        return organizationMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Organization> selectAll() {
        return organizationMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Organization organization) {
        return organizationMapper.updateByPrimaryKey(organization);
    }

    @Override
    public PageResult query(QueryObject qo) {
        Integer totalCount = organizationMapper.queryforCount(qo);
        if (totalCount==0){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<Organization> data = organizationMapper.queryforList(qo);
        return new PageResult(totalCount,data);
    }


}
